package com.fruit.normal.exception;

public class FruitException extends RuntimeException {

	/**
	 * @auth 梁景皓
	 */
	private static final long serialVersionUID = -5072304230641786977L;
	
	// error code
	private String errorCode;
	
	public FruitException() {
		super();
	}
	
	@Deprecated
	public FruitException(String errorCode) {
		this(errorCode, "No Error Message For Error Code");
	}

	public FruitException(String code, String message) {
		this(code, message, null);
	}
	
	public FruitException(FruitExceptionEnum t, String... args) {
		this(t.getCode(), t.getMessage(args), null);
	}
	
	public FruitException(String errorCode, String message, Throwable cause) {
		super(message, cause);
		this.setErrorCode(errorCode);
	}

	public String toString() {
		String className = getClass().getName();
		return String.format(className + ": %1$s--%2$s", this.getErrorCode(),
				this.getMessage());
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorCode() {
		return errorCode;
	}
}
